<script setup lang="ts">
import { Handle, Position } from '@vue-flow/core';
import { NIcon } from 'naive-ui';
import { Edit, Menu } from '@vicons/carbon';

interface NodeData {
  label: string;
  description?: string;
}

defineProps<{
  id: string;
  data: NodeData;
}>();
</script>

<template>
  <div class="start-node">
    <!-- 顶部标题栏 -->
    <div class="node-header">
      <div class="node-title">
        {{ data.label }}
      </div>
      <div class="edit-icon">
        <NIcon :size="14">
          <Edit />
        </NIcon>
      </div>
      <div class="menu-icon">
        <NIcon :size="18">
          <Menu />
        </NIcon>
      </div>
    </div>

    <!-- 节点内容 -->
    <div class="node-body">
      <div class="node-description">
        {{ data.description || '全部人可发起' }}
      </div>
    </div>

    <!-- 只有底部输出连接点 -->
    <Handle type="source" :position="Position.Bottom" class="handle" />
  </div>
</template>

<style scoped>
.start-node {
  border-radius: 8px;
  background: white;
  min-width: 240px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.2s;
  position: relative;
  overflow: visible;
}

.start-node:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.node-header {
  background: linear-gradient(135deg, #8b7cfa 0%, #9d8efb 100%);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  border-radius: 8px 8px 0 0;
}

.node-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

.edit-icon,
.menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.edit-icon:hover,
.menu-icon:hover {
  opacity: 1;
}

.node-body {
  padding: 16px;
  background: white;
}

.node-description {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
}

.handle {
  width: 8px;
  height: 8px;
  background: #8b7cfa;
  border: 2px solid white;
  border-radius: 50%;
}
</style>
